package cn.service.orderService.OrderServiceImpl;

import cn.service.orderService.OrderService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import entity.orderEntity.Order;
import entity.orderEntity.OrderConditon;
import entity.Result;
import mapper.orderMapper.OrderMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 朱颢阳
 * @description
 * @time 2024/8/27 16:27
 */
@Service
public class OrderServiceImpl implements OrderService {
    @Resource
    OrderMapper mapper;

    @Override
    public Result selectAll(OrderConditon orderConditon) {
        PageHelper.startPage(orderConditon.getCurrentPage(),orderConditon.getPageSize());
        Page<Order> page= (Page<Order>) mapper.selectAll(orderConditon);
        return Result.success((int)page.getTotal(),page.getResult());
    }

    @Override
    public Result deleteorder(Integer id) {
        if (mapper.deleteByPrimaryKey(id)>0){
            return Result.success("删除成功");
        }else{
            return Result.failed(200,"删除失败！");
        }
    }

    @Override
    public Result getOrderAll(Integer order_id) {
        return Result.success(200,mapper.selectByPrimaryKey(order_id));
    }

}
